#include "plane.h"
#include "config.h"
plane::plane()
{
    m_plane.load(":/picture/images/me2.png");
    m_x=(GAME_WIDTH-m_plane.width())*0.5;
    m_y=GAME_HEIGHT-m_plane.height();
    m_Rect.setWidth(m_plane.width());
    m_Rect.setHeight(m_plane.height());
    m_Rect.moveTo(m_x,m_y);
}

void plane::shoot()
{
    //累加时间间隔记录变量
    m_recorder++;
    if(m_recorder<BULLET_INTERVAL)
    {
        return;
    }
    m_recorder=0;
    for(int i=0;i<BULLET_NUM;i++)
    {
        if(m_bullet[i].m_free)
        {
            m_bullet[i].m_free=false;
            m_bullet[i].m_x=m_x + m_Rect.width()*0.5-2;
            m_bullet[i].m_y=m_y-20;
            break;
        }
    }
}

void plane::setPosition(int x, int y)
{
    m_x=x;
    m_y=y;
    m_Rect.moveTo(m_x,m_y);
}
